package com.threeti.jiayusms.interfaces.ws.communicationrule;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.CommunicationRule;
import com.threeti.jiayusms.domain.service.communicationrule.CommunicationRuleQueryService;
import com.threeti.jiayusms.interfaces.ws.communicationfunction.CommunicationFunctionDto;

@WebService(serviceName = "RuleTemplateService", portName = "RuleTemplateServicePort", 
		endpointInterface = "com.threeti.jiayusms.interfaces.ws.communicationrule.RuleTemplateWebService", 
		targetNamespace = "http://127.0.0.1:8080/sms-maintenance-main" )
@Transactional
public class RuleTemplateWebServiceDelegate implements RuleTemplateWebService {

	@Autowired
	private CommunicationRuleQueryService queryService;
	
	@Override
	public CommunicationRuleDto findCommunicationRuleBy(String ruleId) {
		CommunicationRule ruleTemplate = queryService.findCommunicationRuleBy(ruleId);
		
		if(ruleTemplate == null){
			return null;
		}
		
		CommunicationRuleDto dto = new CommunicationRuleDto(
				ruleTemplate.getSendCount(),
				ruleTemplate.getSendInterval(),
				ruleTemplate.getDescription());
		
		return dto;
	}
	
	@Override
	public List<CommunicationRuleDto> findCommunicationRuleByList(){
		List<CommunicationRuleDto> dto = new ArrayList<CommunicationRuleDto>();
		
		return dto;
	}
	
}
